<?php

namespace app\admin\controller\zzyy;

use app\admin\model\zzyy\ZzyySetting;
use app\common\controller\Backend;

/**
 * 
 *
 * @icon fa fa-circle-o
 */
class Setting extends Backend
{

    protected $model = null;


    public function _initialize()
    {
        parent::_initialize();
        $this->model = new ZzyySetting();
    }



    public function rentEdit($ids = null)
    {
        $rentReserveAdvanceDay = $this->model->where('name', 'rent_reserve_advance_day')->find();
        $rentAtLeastMin = $this->model->where('name', 'rent_at_least_min')->find();
        $rentRefund = $this->model->where('name', 'rent_refund')->find();
        $unlockInadvanceMin = $this->model->where('name', 'unlock_inadvance_min')->find();
        $payCountdownSec = $this->model->where('name', 'pay_countdown_sec')->find();
        if ($this->request->isPost()) {
            $rentReserveAdvanceDay->value = $this->request->post('rent_reserve_advance_day');
            $rentReserveAdvanceDay->save();

            $rentAtLeastMin->value = $this->request->post('rent_at_least_min');
            $rentAtLeastMin->save();

            $rentRefund->value = $this->request->post('rent_refund');
            $rentRefund->save();

            $unlockInadvanceMin->value = $this->request->post('unlock_inadvance_min');
            $unlockInadvanceMin->save();

            $payCountdownSec->value = $this->request->post('pay_countdown_sec');
            $payCountdownSec->save();

            $this->success("保存成功");

        }
        $this->view->assign('rent_reserve_advance_day', $rentReserveAdvanceDay->value);
        $this->view->assign('rent_at_least_min', $rentAtLeastMin->value);
        $this->view->assign('rent_refund', $rentRefund->value);
        $this->view->assign('unlock_inadvance_min', $unlockInadvanceMin->value);
        $this->view->assign('pay_countdown_sec', $payCountdownSec->value);

        return $this->view->fetch();
    }


}
